<?php

/*
Admin Custom Pages (admin_customize_pages.php)
*/

$page_title = "Customize Pages";
$rank_check = 7;
include "../header.inc.php";

$game=$_GET['game'];
$page=$_GET['page'];

if ($page == "edit2")
{
	$edit = $_GET['edit'];
	$page_info=$_POST['page_info'];
	mysql_query("DELETE FROM game_pages WHERE page_title = '$edit' AND game = '$game'");
	if ($page_info!="")
	{
		mysql_query("INSERT INTO game_pages (game,page_title,page_info) VALUES 	('$game','$edit','$page_info')");
	}
	header("Location: admin_customize_pages.php?game=$game");
}

print "$openHTML";

if (!$page)
{
ECHO <<<END
<p>Want to make your game more unique? Just select a page from the list below and click the submit button! There are special codes to automatically put certain values in, other then that you can add your own text and even your own images! By making your game more unique it makes it much easier to get new members who will continue to come back! You will need at least basic HTML skills for this to work properly. You will also be responsible for making sure everything works, for example if you change the Daily Item image, you will be responsible to make sure the link to play is correct. Well, have fun!</p>

<p>
<FORM ACTION="admin_customize_pages.php?game=$game&page=edit" METHOD=POST>
<select name=edit_page>
<option>Select a Page</option>
<option value="Home - Not Logged In">Home Page (not logged in) [index.php]</option>
<option value="Home - Logged In">Home Page (logged in) [index.php]</option>
<option value="Bank">Bank [bank.php]</option>
<option value="Daily Item - About to Play">Daily Item - About to Play [daily_item.php]</option>
<option value="Daily Item - Already Played">Daily Item - Already Played [daily_item.php]</option>
<option value="Forums">Forums [forums.php]</option>
<option value="Forums - Last 50">Forums - Last 50 [last_50.php]</option>
<option value="Forums - View Category">Forums - View Category [view_cat.php]</option>
<option value="Forums - View Topic">Forums - View Topic [view_topic.php]</option>
<option value="Games">Games [games.php]</option>
<option value="My Stuff">My Stuff [mystuff.php]</option>
<option value="Official Shops">Official Shops [shops.php]</option>
<option value="Quests">Quests [quests.php]</option>
<option value="Referral Contest">Referral Contest [refer.php]</option>
<option value="Updates">Updates [updates.php]</option>
</select>
<input type=submit value="Edit Page!">
</FORM>
</p>
END;
}

if ($page == "edit")
{

$edit_page = $_POST['edit_page'];

$findPage = fetch("SELECT * FROM game_pages WHERE page_title = '$edit_page' AND game = '$game'");
if ($findPage[page_info]) { $pageInfo = "$findPage[page_info]"; }
if (!$findPage[page_info]) { $pageInfo = "[Default Page Info] -- Only change this if you are editing the page."; }


ECHO <<<END

<p align=center>
Click <A href=cust_codes.php?game=$game>here</a> to see codes you can enter to automatically put<Br>
in values such as Username, Date, Time, Game ID, Game Name<Br>
and all sorts of other cool things like that!</p>

<p align=center>
<b>Remember:</b> You can always delete everything in the box<Br>
and it will set that page back to the default text!</p>

<p>Extra Code Used on this page:<Br>

END;

if ($edit_page == "Home - Not Logged In")
{
	print "
	(update1) - Shows most recent update<Br>
	(update2) - Shows 2nd most recent update<br>
	(update3) - Shows 3rd most recent update<br>
	(headline1) - Shows the first headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(headline2) - Shows the second headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(headline3) - Shows the third headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(newestmember) - Shows the most recent user that joined your game.
	";
}

if ($edit_page == "Home - Logged In")
{
	print "
	(update1) - Shows most recent update<Br>
	(update2) - Shows 2nd most recent update<br>
	(update3) - Shows 3rd most recent update<br>
		(headline1) - Shows the first headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(headline2) - Shows the second headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(headline3) - Shows the third headline, defined by you, <a href=admin_headlines.php?game=$game>here</a>.<br>
	(newestmember) - Shows the most recent user that joined your game.
	";
}

if ($edit_page == "Forums - View Category")
{
	print "
	(category) - Shows the category you are currently in<Br>
	(categoryid) - Shows the category ID you are currently in
	";
}

if ($edit_page == "Forums - View Topic")
{
	print "
	(category) - Shows the category you are currently in<br>
	(categoryid) - Shows the category ID you are currently in<br>
	(topic) - Shows the name of the topic you are currently in
	";
}

ECHO <<<FORM
</p>

<FORM ACTION="admin_customize_pages.php?game=$game&page=edit2&edit=$edit_page" METHOD=POST>
<TEXTAREA NAME=page_info ROWS=12 COLS=60 WRAP=virtual >$pageInfo</TEXTAREA>
<br>
<input type=submit value="Edit Page!">
</FORM>

FORM;
}

print "$closeHTML";
?>
